package cn.yuanqiao.archive.yuguidang.domain;/**
 * @author 赵常飞
 * @date 2023/9/26 18:24
 */

import cn.yuanqiao.common.annotation.Excel;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 *
 *@AUTHOR:赵常飞
 *@date 2023/9/26 18:24
 */
public class YuguidangArchiveForm extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private final String BIGTABLENAME = "_YUGD_FORM";

    public YuguidangArchiveForm() {
        String tenantCode = SecurityUtils.getTenantCode();
        if(StringUtils.isEmpty(tenantCode)){
            throw new ServiceException("TenantCode is null");
        }else {
            this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
        }
    }
    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    /**
     * 表单ID
     */
    private String formId;

    /**
     * 表单批次号
     */
    @Excel(name = "表单批次号")
    private String formNo;

    /**
     * 分单号
     */
    @Excel(name = "分单号")
    private String splitNo;

    /**
     * 档案ID
     */
    @Excel(name = "档案ID")
    private String archiveId;

    /**
     * 门类ID
     */
    @Excel(name = "门类ID")
    private Long categoryId;

    /**
     * 门类ID
     */
    @Excel(name = "门类ID")
    private String categoryIdaf;

    /**
     * 状态
     */
    @Excel(name = "状态")
    private String state;

    /**
     * 发起人
     */
    @Excel(name = "发起人")
    private String submitUser;

    /**
     * 发起人ID
     */
    private String submitUserId;

    /**
     * 发起时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "发起时间", width = 30, dateFormat = "yyyy-MM-dd")
    //@JSONField(format = "yyyy-MM-dd")
    private Date submitTime;

    /**
     * 发起部门
     */
    @Excel(name = "发起部门")
    private String submitDept;

    private String REMARK;

    private String daType;

    private String workflowId;

    private String workflowFormId;

    private String submitDeptId;

    private String userId;

    private String tenantCode;

    private String subTableName;

    public String getFormId() {
        return formId;
    }

    public void setFormId(String formId) {
        this.formId = formId;
    }

    public String getFormNo() {
        return formNo;
    }

    public void setFormNo(String formNo) {
        this.formNo = formNo;
    }

    public String getSplitNo() {
        return splitNo;
    }

    public void setSplitNo(String splitNo) {
        this.splitNo = splitNo;
    }

    public String getArchiveId() {
        return archiveId;
    }

    public void setArchiveId(String archiveId) {
        this.archiveId = archiveId;
    }

    @Override
    public Long getCategoryId() {
        return categoryId;
    }

    @Override
    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getCategoryIdaf() {
        return categoryIdaf;
    }

    public void setCategoryIdaf(String categoryIdaf) {
        this.categoryIdaf = categoryIdaf;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getSubmitUser() {
        return submitUser;
    }

    public void setSubmitUser(String submitUser) {
        this.submitUser = submitUser;
    }

    public String getSubmitUserId() {
        return submitUserId;
    }

    public void setSubmitUserId(String submitUserId) {
        this.submitUserId = submitUserId;
    }

    public Date getSubmitTime() {
        return submitTime;
    }

    public void setSubmitTime(Date submitTime) {
        this.submitTime = submitTime;
    }

    public String getSubmitDept() {
        return submitDept;
    }

    public void setSubmitDept(String submitDept) {
        this.submitDept = submitDept;
    }

    public String getREMARK() {
        return REMARK;
    }

    public void setREMARK(String REMARK) {
        this.REMARK = REMARK;
    }

    public String getDaType() {
        return daType;
    }

    public void setDaType(String daType) {
        this.daType = daType;
    }

    public String getWorkflowId() {
        return workflowId;
    }

    public void setWorkflowId(String workflowId) {
        this.workflowId = workflowId;
    }

    public String getWorkflowFormId() {
        return workflowFormId;
    }

    public void setWorkflowFormId(String workflowFormId) {
        this.workflowFormId = workflowFormId;
    }

    public String getSubmitDeptId() {
        return submitDeptId;
    }

    public void setSubmitDeptId(String submitDeptId) {
        this.submitDeptId = submitDeptId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getSubTableName() {
        return subTableName;
    }

    public void setSubTableName(String subTableName) {
        this.subTableName = subTableName;
    }

    public Map<String, Object> toProcessMap() {
        Map<String, Object> map = new HashMap<>();

        // 使用反射获取实体类的字段信息
        Class<?> clazz = this.getClass();
        Field[] fields = clazz.getDeclaredFields();

        try {
            // 遍历所有字段，获取字段名和字段值，并存储到 Map 中
            for (Field field : fields) {
                field.setAccessible(true); // 设置字段可访问，即使是私有字段也可以获取值
                String fieldName = field.getName();
                Object fieldValue = field.get(this); // 获取字段的值
                map.put(fieldName, fieldValue);
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return map;
    }
}
